//
//  HFUIBarButtonItem + Extension.swift
//  sinaMicroBlog
//
//  Created by mac on 15/11/20.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(imageName: String, target: AnyObject?, action: String? ){
        let item = UIButton(type: .Custom)
        item.setBackgroundImage(UIImage(named: imageName), forState: .Normal)
        item.setBackgroundImage(UIImage(named: imageName + "_Highlighted"), forState: .Highlighted)
        if let targetObj = target, actionName = action {
            item.addTarget(targetObj, action: Selector(actionName), forControlEvents: .TouchUpInside)
        }
        item.sizeToFit()
        
        self.init(customView: item)
    }
}
